

//
//  UIImage+Extension.m
//  黑马微博-wzy
//
//  Created by Mac on 2016/11/27.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "UIImage+Extension.h"

@implementation UIImage (Extension)
//根据图片名称自动加载适配 iOS6/ios7 的图片
+ (UIImage *)imageWithName:(NSString *)name{

    UIImage *image = nil;
    if (iOS7) {
        NSString *newName = [name stringByAppendingString:@"_os7"];
        image = [UIImage imageNamed:newName];
    }

    if (image == nil) {
        image = [UIImage imageNamed:name];
    }
    
    return image;
}

//根据图片名返回一张能够自由拉伸的图片
+ (UIImage *)resizedImage:(NSString *)name{
    UIImage *image = [UIImage imageWithName:name];
    
    image = [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
    
//    NSLog(@"image ==== %@", image);
    //LeftCapWidth 左边多少需要保护 topCapHeight:上部多少需要保护
    return image;
}

@end
